package com.jdpc.weparty.reposity

import com.jdpc.weparty.entity.Activity
import com.jdpc.weparty.entity.ActivityType
import com.jdpc.weparty.entity.User
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository


@Repository
interface ActivityRepository : JpaRepository<Activity, Int> {
    /**
     * 根据活动码查找
     */
    fun findByActivityCode(activityCode: String): Activity

    /**
     * 根据活动名称模糊查找
     */
    fun findByActivityNameIgnoreCaseContainingAndCheckedTrue(name: String): List<Activity>
    fun findByActivityNameIgnoreCaseContainingAndCheckedTrue(name: String, pageable: Pageable): Page<Activity>


    /**
     * 根据活动类型查找
     */
    fun findByActivityTypeAndCheckedTrue(activityType: ActivityType): List<Activity>
    fun findByActivityTypeAndCheckedTrue(activityType: ActivityType, pageable: Pageable): Page<Activity>


    /**
     * 查找所有已经通过管理员审核的活动
     */
    fun findByCheckedTrue(): List<Activity>
    fun findByCheckedTrue(pageable: Pageable): Page<Activity>

    /**
     * 查找所有未通过管理员审核的活动
     */
    fun findByCheckedFalse(): List<Activity>
    fun findByCheckedFalse(pageable: Pageable): Page<Activity>

    /**
     * 查找所有尚未审核的活动
     */
    fun findByCheckedIsNull(): List<Activity>
    fun findByCheckedIsNull(pageable: Pageable): Page<Activity>

    /**
     * 查找某用户发布的活动
     */
    fun findByPublisher(publisher: User): List<Activity>
    fun findByPublisher(publisher: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某用户发布的未通过审核的活动
     */
    fun findByPublisherAndCheckedFalse(publisher: User): List<Activity>
    fun findByPublisherAndCheckedFalse(publisher: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某用户发布的已通过审核的活动
     */
    fun findByPublisherAndCheckedTrue(publisher: User): List<Activity>
    fun findByPublisherAndCheckedTrue(publisher: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某用户发布的尚未审核的活动
     */
    fun findByPublisherAndCheckedIsNull(publisher: User): List<Activity>
    fun findByPublisherAndCheckedIsNull(publisher: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某管理员审核的活动
     */
    fun findByExaminer(examiner: User): List<Activity>
    fun findByExaminer(examiner: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某管理员审核未通过的活动
     */
    fun findByExaminerAndCheckedFalse(examiner: User): List<Activity>
    fun findByExaminerAndCheckedFalse(examiner: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某管理员已经审核通过的活动
     */
    fun findByExaminerAndCheckedTrue(examiner: User): List<Activity>
    fun findByExaminerAndCheckedTrue(examiner: User, pageable: Pageable): Page<Activity>

    /**
     * 查找某管理员还未审核的活动
     */
    fun findByExaminerAndCheckedIsNull(examiner: User): List<Activity>
    fun findByExaminerAndCheckedIsNull(examiner: User, pageable: Pageable): Page<Activity>

}